﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace monitor_server
{
    public partial class Form5 : Form
    {
        form5enable d;
        formenable d1;
        Form1 form1 = new Form1();
        public Form5(form5enable sender, formenable sender1)
        {
            InitializeComponent();
            d = sender;
            d1 = sender1;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            d1(false);
            this.Close();
        }

        bool f2 = false;

        void func2(bool param)
        {
            f2 = param;
            d1(false);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" && textBox2.Text == "")
            {
                f2 = true;
                Form2 form2 = new Form2(new formenable(func2));
                form2.Owner = form1;
                form2.Show();
                this.Close();
                return;
            }
            byte[] log = new byte[textBox1.Text.Length];
            byte[] pass = new byte[textBox2.Text.Length];
            log = Encoding.Default.GetBytes(textBox1.Text);
            pass = Encoding.Default.GetBytes(textBox2.Text);
            switch(d(log.Length, log, pass.Length, pass))
            {
                case 1:                    
                    f2 = true;
                    Form2 form2 = new Form2(new formenable(func2));
                    form2.Owner = form1;
                    form2.Show();
                    this.Close();                    
                    break;
                case 2:
                    MessageBox.Show("У вас недостаточно прав.");
                    break;
                case 3:
                    MessageBox.Show("Введены неверные данные.");
                    break;
            }
        }
       
    }
}
